package com.miao.activity.controller;

import java.util.Arrays;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.miao.activity.entity.MiaoActivityEntity;
import com.miao.activity.service.MiaoActivityService;
import com.miao.commonn.utils.PageUtils;
import com.miao.commonn.utils.R;



/**
 * 
 *
 * @author xk
 * @email 2337156522@QQ.com
 * @date 2022-02-22 16:35:05
 */
@RestController
@RequestMapping("activity/miaoactivity")
public class MiaoActivityController {
    @Autowired
    private MiaoActivityService miaoActivityService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = miaoActivityService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{miaoId}")
    public R info(@PathVariable("miaoId") Integer miaoId){
		MiaoActivityEntity miaoActivity = miaoActivityService.getById(miaoId);

        return R.ok().put("miaoActivity", miaoActivity);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody MiaoActivityEntity miaoActivity){
		miaoActivityService.save(miaoActivity);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody MiaoActivityEntity miaoActivity){
		miaoActivityService.updateById(miaoActivity);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] miaoIds){
		miaoActivityService.removeByIds(Arrays.asList(miaoIds));

        return R.ok();
    }

}
